import { getWalletFreezeDetail } from '../../../../../common/api/index'
Page({
    data: {
		tablist: [
			{name:'冻结中',addRed:0},
			{name:'已发放',addRed:1},
		],
		addRed: 0,
		pageNo: 1,
		total: 0,
		detailList: [],
		showLoading: false,
	},
    onLoad() {
		this.getWalletDetailList()
    },
    onShow() {

    },
	// 切换类型
	clickTab(e){
		this.setData({
			addRed: e.detail.name,
			pageNo: 1,
		})
		this.getWalletDetailList()
	},
	// 获取钱包明细
	getWalletDetailList(){
		this.setData({
			showLoading: true
		})
		let data = {
			pageNo: this.data.pageNo,
			pageSize: 10,
			states: this.data.addRed
		}
		getWalletFreezeDetail(data).then(res => {
			if(res.code == 200){
				let data = []
				if(this.data.pageNo == 1){
					data = res.data
				}else{
					data = this.data.detailList.concat(res.data)
				}
				this.setData({
					detailList: data,
					total: res.extend.total,
					showLoading: false
				})
			}
		})
	},
    //页面上拉触底事件的处理函数
    onReachBottom() {
		if(this.data.total > this.data.detailList.length){
			this.setData({
				pageNo: ++this.data.pageNo,
			})
			this.getWalletDetailList()
		}
    },
})